//
//  OrderAddressCell.m
//  sensen_ios
//
//  Created by mc on 16/2/27.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "OrderAddressCell.h"

#import "OrderModel.h"

@implementation OrderAddressCell

+(instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString * cellIdentifier = @"OrderAddressCell";
    OrderAddressCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell ==nil) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self setupSubViews];
        
    }
    return self;
}
- (void)setupSubViews{
    
    UIImageView * imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"订单详情_地址"];
    [self addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.centerY.equalTo(self.mas_centerY).offset(0);
        make.size.mas_equalTo(CGSizeMake(20, 25));
    }];

    
    
    self.nameLable = [[UILabel alloc] init];
    [self addSubview:self.nameLable];
    self.nameLable.font = FONT(12);
    self.nameLable.text = @"博也科技";
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageView.mas_right).offset(10);
        make.top.equalTo(self).offset(10);
        make.size.mas_equalTo(CGSizeMake(150, 25));
    }];
    //self.nameLable.backgroundColor = [UIColor redColor];
    
    
    self.phoneLable = [[UILabel alloc] init];
    [self addSubview:self.phoneLable];
    self.phoneLable.text = @"15868405030";
    self.phoneLable.font = FONT(12);
    self.phoneLable.textAlignment = NSTextAlignmentRight;
    [self.phoneLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-50);
        make.top.equalTo(self).offset(10);
        make.size.mas_equalTo(CGSizeMake(120, 25));
    }];
    //self.phoneLable.backgroundColor = [UIColor redColor];
    
    
    self.addressLable = [[UILabel alloc] init];
    [self addSubview:self.addressLable];
    self.addressLable.font = FONT(12);
    [self.addressLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLable.mas_left).offset(0);
        make.bottom.equalTo(self).offset(-10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 50, 25));
    }];
    self.addressLable.text = @"浙江省杭州市江干区下沙街道金沙湖一号3幢1515";
    //self.addressLable.backgroundColor = [UIColor greenColor];
    
    
    self.nameLable.textColor = [UIColor darkGrayColor];
    self.phoneLable.textColor = [UIColor darkGrayColor];
    self.addressLable.textColor = [UIColor darkGrayColor];
}

- (void)setModel:(OrderModel *)model{
    _model = model;
    self.addressLable.text = [NSString stringWithFormat:@"收货地址:%@%@%@%@",_model.province,_model.city,_model.area,_model.detailinfo];
    self.nameLable.text = [NSString stringWithFormat:@"收货人:%@", _model.contactname];
    self.phoneLable.text = _model.mobile;
}


@end
